/**
 *
 */
package com.angel.data.generator.validators.impl;

import java.lang.reflect.Method;

import com.angel.common.helpers.AnnotationHelper;
import com.angel.common.helpers.ReflectionHelper;
import com.angel.data.generator.annotations.inputStream.InputStreamBuilder;
import com.angel.data.generator.exceptions.DataGeneratorBuilderValidatorException;
import com.angel.data.generator.validators.DataGeneratorBuilderValidator;

/**
 * @author William
 *
 */
public class OnlyOneInputStreamBuilderAnnotationValidator implements DataGeneratorBuilderValidator{

	public void validate(Class<?> dataGeneratorClass) throws DataGeneratorBuilderValidatorException {
		Method[] methods = ReflectionHelper.getAllMethodFor(dataGeneratorClass);
		boolean hasOnlyOne = AnnotationHelper.hasOnlyOneAnnotationInstance(methods, InputStreamBuilder.class);
		if(!hasOnlyOne){
			throw new DataGeneratorBuilderValidatorException("Data object generator class [" + dataGeneratorClass + "] contains [0 or more than 1] InputStreamBuilder annotation.");
		}
	}
}
